cmake_minimum_required(VERSION 3.10)
project(CompileServer)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找依赖包
find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)


# 设置源文件
set(SOURCE_FILES
    compile_server.cc
    compiler.hpp
    runner.hpp
    compile_run.hpp
)

# 添加可执行文件
add_executable(CompileServer ${SOURCE_FILES})

# 设置包含目录
# 当前目录和上级目录（为了访问 comm 文件夹）
target_include_directories(CompileServer PRIVATE 
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/..
    ${JSONCPP_INCLUDE_DIRS}
    ${Boost_INCLUDE_DIRS}
)

# 链接依赖库
target_link_libraries(CompileServer PRIVATE 
    ${JSONCPP_LIBRARIES}
    ${Boost_LIBRARIES}
)

# 确保 temp 目录存在
add_custom_command(TARGET CompileServer POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_SOURCE_DIR}/temp
)